package ms.maplestory.boot.client.character.quest.progress;

import lombok.Getter;
import lombok.Setter;
import ms.maplestory.boot.client.character.Char;
import ms.maplestory.boot.loaders.DatSerializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

@Getter
@Setter
@Entity
@DiscriminatorValue("mob")
public class QuestProgressMobRequirement extends QuestProgressRequirement implements QuestValueRequirement {

    @Column(name = "unitId")
    private int mobId;
    @Column(name = "requiredCount")
    private int requiredCount;
    @Column(name = "currentCount")
    private int currentCount;

    public QuestProgressMobRequirement() {
    }


    @Override
    public String getValue() {
        return String.valueOf(getCurrentCount());
    }

    @Override
    public void write(DataOutputStream dos) throws IOException {
        dos.writeInt(getMobId());
        dos.writeInt(getRequiredCount());
        dos.writeInt(getOrder());
    }

    @Override
    public DatSerializable load(DataInputStream dis) throws IOException {
        QuestProgressMobRequirement questProgressMobRequirement = new QuestProgressMobRequirement();
        questProgressMobRequirement.setMobId(dis.readInt());
        questProgressMobRequirement.setRequiredCount(dis.readInt());
        questProgressMobRequirement.setOrder(dis.readInt());
        return questProgressMobRequirement;
    }

    @Override
    public boolean isComplete(Char chr) {
        return false;
    }

    @Override
    public QuestProgressRequirement deepCopy() {
        QuestProgressMobRequirement questProgressMobRequirement = new QuestProgressMobRequirement();
        questProgressMobRequirement.setMobId(getMobId());
        questProgressMobRequirement.setRequiredCount(getRequiredCount());
        questProgressMobRequirement.setCurrentCount(getCurrentCount());
        questProgressMobRequirement.setOrder(getOrder());
        return questProgressMobRequirement;
    }
}
